<VirtualHost *>
    ServerName {{ inventory_hostname }}

    WSGIDaemonProcess koschei user=koschei group=koschei threads=5 home=/usr/share/koschei

    WSGIScriptAlias /koschei /usr/share/koschei/koschei.wsgi
    Alias /koschei/static /usr/share/koschei/static/
    RewriteEngine on
    RewriteRule ^/koschei/documentation/?$ https://fedoraproject.org/wiki/Koschei [R=301,L]

    <Directory /usr/share/koschei>
        WSGIProcessGroup koschei
        WSGIApplicationGroup %{GLOBAL}
        Options All
        AllowOverride All
        Require all granted
    </Directory>

    <Location /koschei/login>
        Require valid-user
        AuthType OpenID
        AuthOpenIDSingleIdP https://{{ koschei_openid_provider }}/
{% if env == 'staging' %}
        AuthOpenIDServerName https://apps.stg.fedoraproject.org
        AuthOpenIDTrustRoot https://apps.stg.fedoraproject.org/koschei/
{% else %}
        AuthOpenIDServerName https://apps.fedoraproject.org
        AuthOpenIDTrustRoot https://apps.fedoraproject.org/koschei/
{% endif %}
        AuthOpenIDUseCookie off
    </Location>
</VirtualHost>
